package com.netease.nie.dao;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Repository;

import com.netease.nie.base.exceptions.BusinessException;
import com.netease.nie.constants.BusinessConstants;
import com.netease.nie.mapper.OrdersTraceMapper;
import com.netease.nie.model.OrdersTrace;

@Repository
public class OrdersTraceDao {

	@Resource
	private OrdersTraceMapper ordersTraceMapper;

	public List<OrdersTrace> queryOrdersTraceListByOrdersId(long orderId) {
		List<OrdersTrace> ordersTraceList = ordersTraceMapper.queryOrdersTraceListByOrdersId(orderId);
		if (ordersTraceList == null || ordersTraceList.isEmpty())
			throw new BusinessException(BusinessConstants.ORDER_TRACE_NOT_EXISTS.getCode(), "商品跟踪信息不存在");
		
		return ordersTraceList;
	}

	public void insertOrdersTrace(OrdersTrace ordersTrace) throws Exception {
		ordersTraceMapper.insertOrdersTrace(ordersTrace);
	}
	
	public List<OrdersTrace> queryCurrentStatusOrdersTracesByOrderIds(List<Long> orderIds) {
		return ordersTraceMapper.queryCurrentStatusOrdersTracesByOrderIds(orderIds);
	}
}
